from django.contrib import admin
from minik.models import Data_message


# Register your models here.
@admin.register(Data_message)
class Data_messageadmin(admin.ModelAdmin):
    fieldsets = (
        ('主要信息',{
        'fields':('channel','content','state',)
        }),
    )
    list_display = ('channel','profile','state','postTime')
    list_display_links = ('channel', 'profile',)
    actions = []
    
    def has_delete_permission(self, request, obj=None):
        return False
    
    def save_model(self, request, obj, form, change):
        obj.sysId = -1
        if obj.action is None:
            obj.action = 0
            
        admin.ModelAdmin.save_model(self, request, obj, form, change)
#     
#     def has_add_permission(self, request):
#         return False
    
    def get_actions(self, request):
        actions = super(Data_messageadmin, self).get_actions(request)
        del actions['delete_selected']
        return actions
